//
//  CommitFooterView.m
//  StandardizedProduct
//
//  Created by 宁宁 on 16/7/1.
//  Copyright © 2016年 ym. All rights reserved.
//

#import "CommitFooterView.h"

@implementation CommitFooterView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
//        [self setView];
    }
    return self;
}


- (void)setView{
//    _total = @"2000.00";    // 总价
//    _freight = @"0.00" ;    // 运费
    
    NSString *footerStr = [NSString stringWithFormat:@"合计:¥ %@(含运费¥ %@)", _total, _freight];
    
    
    UILabel *footerLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 15, 1000, 20)];
    footerLabel.backgroundColor = [UIColor clearColor];
    NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:footerStr];
    
    [AttributedStr addAttribute:NSFontAttributeName
                          value:[UIFont systemFontOfSize:14.0]
                          range:NSMakeRange(0, footerStr.length)];
    
    //价格
    // 修改价格字体大小
    [AttributedStr addAttribute:NSFontAttributeName
                          value:[UIFont systemFontOfSize:20.0]
                          range:NSMakeRange(5, _total.length - 3)];

    
    footerLabel.attributedText = AttributedStr;
    [footerLabel sizeToFit];
    
    [self addSubview:footerLabel];
    
    
    _commit = [UIButton buttonWithType:UIButtonTypeCustom];
    _commit.frame = CGRectMake(SCREEN_WIDTH - 90, 8, 80, 34);
    _commit.backgroundColor = APPCOLOR;
    [_commit setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    _commit.titleLabel.font = [UIFont systemFontOfSize:15];
    [_commit setTitle:@"确认付款" forState:UIControlStateNormal];
    _commit.layer.cornerRadius = 5;
    _commit.layer.masksToBounds = YES;
    [_commit addTarget:self action:@selector(commitOrder) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_commit];
}

- (void)commitOrder{
    _commitOrderClick();
}

@end
